Definitions
forewords (note easier to start with less organizational structure and build) LISP- mccarthy nlab/category theory number base systems number 'types' exclude 'side notes' aka 'comprised of procedures and data, which will later be shown to be not that different' definitions expressions: primitive expressions, which represent the simplest entities the language is concerned with. includes: numbers * the values of numerals are the numbers that they name * the values of built-in operators are the machine instruction sequences that carry out the corresponding operations * the values of other names are the objects associated with those names in the environment +, *, (), line break 486 486; (+ 137 349) 486; means of combination, by which compound elements are built from simpler ones means of abstraction, by which compound elements can be named and manipulated as units. expression- can represent numbers, primitive procedures, can form a compound expression evaluating combination, can be a list of expressions within parentheses to denote procedure application operator leftmost element in list operand other elements in list arguments '''the value of a combination is obtained by applying the procedure specified by the operator to the arguments that are the values of the operands '''prefix notation '''the convention of placing the operator to the left of the operands '''nested combinations '''combinations where the elements are themselves combinations (+ ( * 3 5) (- 10 6)) 19; '''pretty printing '''a formatting convention in which each long combination i written so that the operands are aligned vertically (+ (* 3 (+ (* 2 4) (+ 3 5))) (+ (- 10 7) 6)); '''read-eval-print loops '''the interpreter operates in this cycle: it reads an expression from the terminal, evaluates the expression, and prints the result '''naming and the environment: variable '''the name given to computational objects whose '''value '''is the object '''define '''used to name things in lisp ex/ (define size 2) size 2; '''global environment '''to associate values with symbols and later retrieve them, the interpreter must maintainsome sort of memory that keeps track of name-object pairs, this is called the environment or the global environment '''evaluating combinations: the evaluation rule '''is: # evaluate the subexpressions of the combination # apply the procedure that is the value of the left most subepression (the operator) to the arguments that are the values of the other subexpressions (the operands) a '''recursive '''process includes, as one of its steps, the need to invoke the rule itself The "percolate values upward" form of the evaluation rule is an example of a general process known as '''Tree Accumulation special forms are exceptions to the general evaluation rule. each has its own evaluation rule. e.g. define compound procedures: procedure definitions are a powerful abstraction technique by which a compound operation can be given a name and then referred to as a unit. The general form of a procedure definition is (define ( (formal parameters) ); (define (square x) (* x x)); is a symbol to be associated with the procedure definition in the environment. the are the names used within the body of the procedure to refer to the corresponding arguments of the procedure. the is an expression that will yield the value of the procedure application when the formal parameters are replaced by the actual arguments to which the procedure is applied. (define (sum-of-squares x y) (+ (square x) (square y))); (define (f a) (sum-of-squares (+ a 1) (* a 2))) (f 5) 136;